package net.godbirds.api.wf;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import net.godbirds.aps.wf.WorkFlowService;
import net.godbirds.domain.model.TWfDef;

@RestController
@RequestMapping(value="/wf")
public class WorkFlowController {

	@Autowired
	WorkFlowService workFlowService;
	
	@RequestMapping(value="/wfManageUrl",
			method=RequestMethod.GET)
	public ModelAndView wfManageUrl() {
		ModelAndView mav = new ModelAndView("manage/wf/WFEdit");
		return mav;
	}
	@RequestMapping(value="/wfHelpUrl",
			method=RequestMethod.GET)
	public ModelAndView wfHelpUrl() {
		ModelAndView mav = new ModelAndView("manage/wf/WFHelp");
		return mav;
	}
	@RequestMapping(value="/adapteEdit",
			method=RequestMethod.POST,
			produces="application/json;charset=utf-8")
	@ResponseBody
	public Map<String,Object> wfMamageUrl(){
		Map<String,Object> rtv = new HashMap<String,Object>();
		rtv.put("msg", "添加失败");
		return rtv;
	}
	@RequestMapping(value="/addWfDef",
			method=RequestMethod.POST,
			produces="application/json;charset=utf-8")
	@ResponseBody
	public Map<String,Object> wfAdd(@RequestBody TWfDef tWfDef){
		Map<String,Object> rtv = new HashMap<String,Object>();
		int i = workFlowService.add(tWfDef);
		rtv.put("msg", "添加失败");
		if(i>0) {
			rtv.put("msg", "添加成功");
		}
		return rtv;
	}
}
